import os
import random

def Shared_password_button():
    text = "The password should contain: \n"
    text = text + "1) minimum 10 characters\n"
    text = text + "2) maximum 254 characters\n"
    text = text + "3) one number 0123456789\n"
    text = text + "4) one special character !@#$%^&*()-_+=[]{}<>?/|\\`~;:\n"
    text = text + "5) one lower case letter abcdefghijklmnopqrstuvwxyz\n"
    text = text + "6) one upper case letter ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
    open_text_popup(text)

def Local_password_button():
    text = "The password should contain: \n"
    text = text + "1) minimum 10 characters\n"
    text = text + "2) maximum 254 characters\n"
    text = text + "3) one number 0123456789\n"
    text = text + "4) one special character !@#$%^&*()-_+=[]{}<>?/|\\`~;:\n"
    text = text + "5) one lower case letter abcdefghijklmnopqrstuvwxyz\n"
    text = text + "6) one upper case letter ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
    open_text_popup(text)

def xmessage_load_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str

    combobox_obj = get_from_layout ( slayout_local, "xmessage_load_command" )

    if ( combobox_obj != None ) :

        # put all the buttons to read_only excepted the selected one

        selection = combobox_obj["fields"][2]["selection"].replace("(","").replace(")","").replace(" ","_")
        for item in combobox_obj["fields"][2]["items"] :

            ids = item["display"].replace("(","").replace(")","").replace(" ","_")
            button_obj = get_from_layout ( slayout_local, ids )

            if ids == selection :
                button_obj["permission"] = "read_write"
            else :
                button_obj["permission"] = "read_only"

            slayout_local = set_to_layout( slayout_local, button_obj )

        # build a list of files id and file types

        all_files_id = [ "Local_encoding_parameters", "Local_xmatrix_compressed", "Local_xmatrix", \
                         "Local_start_point", "Local_monomial_key", "Local_binomial_key", \
                         "Local_plain_text_message", "Local_decrypted_message", "Sender_binomial_key", \
                         "Shared_encoding_parameters", "Shared_initial_encoding_parameters", "Shared_encrypted_message", "Shared_ring_signature", \
                         "Shared_xmatrix_compressed", "Shared_start_point", "Shared_binomial_key", "Local_received_ring_signature" ]

        number_of_Decoy_binomial_keys = 0
        obj = get_from_layout ( slayout_local, "ring_signature_size" )
        for item in obj["fields"][2]["items"] :
            display_n = int ( item["display"] )
            if ( number_of_Decoy_binomial_keys < display_n ) :
                number_of_Decoy_binomial_keys = display_n

        for i in range ( 0, number_of_Decoy_binomial_keys ) :
            all_files_id = all_files_id + [ "Decoy_binomial_key_" + str(i) ]

        # set all the files to read_only and input files and passwords to read_only

        for fid in all_files_id :
            path_obj = get_from_layout ( slayout_local, fid )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_only" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        string_obj = get_from_layout ( slayout_local, "Local_password" )
        string_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, string_obj )

        string_obj = get_from_layout ( slayout_local, "Local_repeat_password" )
        string_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, string_obj )

        string_obj = get_from_layout ( slayout_local, "Shared_password" )
        string_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, string_obj )

        string_obj = get_from_layout ( slayout_local, "Shared_repeat_password" )
        string_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, string_obj )

        comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
        comb_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, comb_obj )

        comb_obj = get_from_layout ( slayout_local, "ring_signature_size" )
        comb_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, comb_obj )

        string_obj = get_from_layout ( slayout_local, "rename_Decoy_binomial_key" )
        string_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, string_obj )

        obj = get_from_layout ( slayout_local, "Decoy_binomial_key_names" )
        obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, obj )

        button_obj = get_from_layout ( slayout_local, "view_Decoy_binomial_key" )
        button_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, button_obj )

        path_obj = get_from_layout ( slayout_local, "Local_received_ring_signature" )
        path_obj["permission"] = "read_only" 
        slayout_local = set_to_layout( slayout_local, path_obj )

        # set correct permission and direction to files
        if selection == "generate_Local_encoding_param" :

            string_obj = get_from_layout ( slayout_local, "Local_password" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            string_obj = get_from_layout ( slayout_local, "Local_repeat_password" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Shared_encoding_param" :

            path_obj = get_from_layout ( slayout_local, "Shared_initial_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            string_obj = get_from_layout ( slayout_local, "Shared_password" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            string_obj = get_from_layout ( slayout_local, "Shared_repeat_password" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Local_xmatrix_compressed" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_xmatrix_compressed" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "decompress_Local_xmatrix" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Local_start_point" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_start_point" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_start_point" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Local_monomial_key" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "load_Shared_xmatrix_compressed" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_xmatrix_compressed" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "load_Shared_start_point" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_start_point" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_start_point" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Local_binomial_key" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_start_point" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_binomial_key" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_Shared_Local_binomial_key" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_binomial_key" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "generate_random_Decoy_binomial_keys" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_start_point" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            button_obj = get_from_layout ( slayout_local, "view_Decoy_binomial_key" )
            button_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, button_obj )

            for i in range( 0, number_of_Decoy_binomial_keys ):
                path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )
                path_obj["fields"][2]["direction"] = "output" 
                slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + comb_obj["fields"][2]["selection"] )
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            string_obj = get_from_layout ( slayout_local, "rename_Decoy_binomial_key" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            obj = get_from_layout ( slayout_local, "Decoy_binomial_key_names" )
            obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, obj )

        elif selection == "load_Shared_Decoy_binomial_key" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            for i in range( 0, number_of_Decoy_binomial_keys ):
                path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )
                path_obj["fields"][2]["direction"] = "output" 
                slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + comb_obj["fields"][2]["selection"] )
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            string_obj = get_from_layout ( slayout_local, "rename_Decoy_binomial_key" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            obj = get_from_layout ( slayout_local, "Decoy_binomial_key_names" )
            obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, obj )

        elif selection == "encrypt_and_sign_message" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_plain_text_message" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            for i in range( 0, number_of_Decoy_binomial_keys ):
                path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )
                path_obj["fields"][2]["direction"] = "input" 
                slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + comb_obj["fields"][2]["selection"] )
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            comb_obj = get_from_layout ( slayout_local, "ring_signature_size" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encrypted_message" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_ring_signature" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            string_obj = get_from_layout ( slayout_local, "rename_Decoy_binomial_key" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            obj = get_from_layout ( slayout_local, "Decoy_binomial_key_names" )
            obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, obj )

        elif selection == "verify_and_decrypt_message" :

            path_obj = get_from_layout ( slayout_local, "Local_received_ring_signature" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_decrypted_message" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_ring_signature" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Sender_binomial_key" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_decrypted_message" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encrypted_message" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        elif selection == "encrypt_sign_and_permute" :

            path_obj = get_from_layout ( slayout_local, "Local_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encoding_parameters" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_plain_text_message" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_xmatrix" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            for i in range( 0, number_of_Decoy_binomial_keys ):
                path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )
                path_obj["fields"][2]["direction"] = "input" 
                slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_" + comb_obj["fields"][2]["selection"] )
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            comb_obj = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            comb_obj = get_from_layout ( slayout_local, "ring_signature_size" )
            comb_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, comb_obj )

            path_obj = get_from_layout ( slayout_local, "Local_monomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Local_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_encrypted_message" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_ring_signature" )
            path_obj["fields"][2]["direction"] = "output" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            path_obj = get_from_layout ( slayout_local, "Shared_binomial_key" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

            string_obj = get_from_layout ( slayout_local, "rename_Decoy_binomial_key" )
            string_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, string_obj )

            obj = get_from_layout ( slayout_local, "Decoy_binomial_key_names" )
            obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, obj )

            path_obj = get_from_layout ( slayout_local, "Local_received_ring_signature" )
            path_obj["fields"][2]["direction"] = "input" 
            path_obj["permission"] = "read_write" 
            slayout_local = set_to_layout( slayout_local, path_obj )

        render_layout(  slayout_local )

    return 0

def generate_Local_encoding_param_button ( ) :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0 ; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Local_encoding_param" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    string_obj = get_from_layout ( slayout_local, "Local_password" )
    first_password = string_obj["fields"][2]["display"] 
    first_password_display = string_obj["fields"][0]["display"] 

    string_obj = get_from_layout ( slayout_local, "Local_repeat_password" )
    second_password = string_obj["fields"][2]["display"] 
    second_password_display = string_obj["fields"][0]["display"] 

    error, popup_obj = check_passwords( first_password, first_password_display, second_password, second_password_display, row_index, popup_obj )

    if error == 0 :
        dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( dump_encoding_param, row_index, popup_obj )

    # build command
    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "dump encoding param" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --encoding-conf -compiled-param -password-str \"" + first_password + "\" " 
        cmd_str = cmd_str + logging_str + " --dump-encoding-param -encoding-param " + dump_encoding_param 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str.replace(first_password,"xxxxxxx") })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )

        error, popup_obj = check_encoding_param_wrapper( dump_encoding_param, cache_dir, first_password, architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def generate_Shared_encoding_param_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Shared_encoding_param" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    string_obj = get_from_layout ( slayout_local, "Shared_password" )
    first_password = string_obj["fields"][2]["display"] 
    first_password_display = string_obj["fields"][0]["display"] 

    string_obj = get_from_layout ( slayout_local, "Shared_repeat_password" )
    second_password = string_obj["fields"][2]["display"] 
    second_password_display = string_obj["fields"][0]["display"] 

    error, popup_obj = check_passwords( first_password, first_password_display, second_password, second_password_display, row_index, popup_obj )

    if error == 0 :
        Shared_initial_encoding_parameters = get_from_layout ( slayout_local, "Shared_initial_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_initial_encoding_parameters, cache_dir, first_password, architecture, popup_obj, row_index )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Shared_dump_encoding_param, row_index, popup_obj )

    # build command
    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "dump encoding param" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --encoding-conf -encoding-param " + Shared_initial_encoding_parameters + " -password-str  \"" + first_password + "\" " 
        cmd_str = cmd_str + logging_str + " --dump-encoding-param -encoding-param " + Shared_dump_encoding_param 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str.replace(first_password,"xxxxxxx") })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, first_password, architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)

    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def generate_Local_xoron_matrix_compressed_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0 ; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Local_xoron_matrix_compressed" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix_compressed = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_xmatrix_compressed, row_index, popup_obj )

    if error == 0 :
        Shared_xmatrix_compressed = get_from_layout ( slayout_local, "Shared_xmatrix_compressed" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Shared_xmatrix_compressed, row_index, popup_obj )

    # build commands
    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "mine xmatrix comp ot" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " " 
        cmd_str = cmd_str + logging_str + " --mine-xmatrix-comp-ot -random -xmatrix-comp " + Local_xmatrix_compressed 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_matrx_compressed_wrapper( Local_xmatrix_compressed, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Local_xmatrix_compressed + " -to-encode " + Shared_xmatrix_compressed 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_matrx_compressed_wrapper( Shared_xmatrix_compressed, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)

    popup_str = json.dumps(popup_obj)
    os.system("rm -rf " + cache_dir)
    return popup_str

def decompress_Local_xoron_matrix_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0 ; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "decompress_Local_xoron_matrix" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix_comp = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )["fields"][2]["display"]
        error, popup_obj = check_matrx_compressed_wrapper( Local_xmatrix_comp, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_xmatrix, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "mine xmatrix" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --sequence-conf -xmatrix-comp " + Local_xmatrix_comp + " " 
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " " 
        cmd_str = cmd_str + logging_str + " --decompress-xmatrix -xmatrix " + Local_xmatrix 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def generate_Local_start_point_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0 ; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Local_start_point" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_start_point = get_from_layout ( slayout_local, "Local_start_point" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_start_point, row_index, popup_obj )

    if error == 0 :
        Shared_start_point = get_from_layout ( slayout_local, "Shared_start_point" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Shared_start_point, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make start point" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " " 
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " " 
        cmd_str = cmd_str + logging_str + " --make-start-point -start-point " + Local_start_point 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_start_point_wrapper( Local_start_point, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Local_start_point + " -to-encode " + Shared_start_point 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_start_point_wrapper( Shared_start_point, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def generate_Local_monomial_key_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Local_monomial_key" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_monomial_key = get_from_layout ( slayout_local, "Local_monomial_key" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_monomial_key, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make monomial key" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-monomial-key -monomial-key " + Local_monomial_key

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_monomial_key_wrapper( Local_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)

    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def load_Shared_xoron_matrix_compressed_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "load_Shared_xoron_matrix_compressed" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_xmatrix_compressed = get_from_layout ( slayout_local, "Shared_xmatrix_compressed" )["fields"][2]["display"]
        error, popup_obj = check_matrx_compressed_wrapper( Shared_xmatrix_compressed, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix_compressed = get_from_layout ( slayout_local, "Local_xmatrix_compressed" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_xmatrix_compressed, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_xmatrix_compressed + " -to-encode " + Local_xmatrix_compressed 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_matrx_compressed_wrapper( Local_xmatrix_compressed, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)

    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def load_Shared_start_point_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "load_Shared_start_point" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_start_point = get_from_layout ( slayout_local, "Shared_start_point" )["fields"][2]["display"]
        error, popup_obj = check_start_point_wrapper( Shared_start_point, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_start_point = get_from_layout ( slayout_local, "Local_start_point" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_start_point, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_start_point + " -to-encode " + Local_start_point 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_start_point_wrapper( Local_start_point, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def generate_Local_binomial_key_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Local_binomial_key" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_start_point = get_from_layout ( slayout_local, "Local_start_point" )["fields"][2]["display"]
        error, popup_obj = check_start_point_wrapper( Local_start_point, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_monomial_key = get_from_layout ( slayout_local, "Local_monomial_key" )["fields"][2]["display"]
        error, popup_obj = check_monomial_key_wrapper( Local_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_binomial_key = get_from_layout ( slayout_local, "Local_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_binomial_key, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make binomial key" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --arithmetic-conf -start-point " + Local_start_point + " -monomial-key " + Local_monomial_key + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-binomial-key -binomial-key " + Local_binomial_key

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( Local_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def generate_Shared_Local_binomial_key_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_Shared_Local_binomial_key" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_binomial_key = get_from_layout ( slayout_local, "Local_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Local_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_binomial_key = get_from_layout ( slayout_local, "Shared_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Shared_binomial_key, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Local_binomial_key + " -to-encode " + Shared_binomial_key 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( Shared_binomial_key, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def generate_random_Decoy_binomial_keys_button():

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "generate_random_Decoy_binomial_keys" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_start_point = get_from_layout ( slayout_local, "Local_start_point" )["fields"][2]["display"]
        error, popup_obj = check_start_point_wrapper( Local_start_point, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Decoy_monomial_key = cache_dir + "/temporary_monomial_key_" + str(random.randint(0,10000))
        keynum = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )["fields"][2]["selection"]
        Decoy_binomial_key = get_from_layout ( slayout_local, "Decoy_binomial_key_" + keynum )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Decoy_binomial_key, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make monomial key" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-monomial-key -monomial-key " + Decoy_monomial_key

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_monomial_key_wrapper( Decoy_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make binomial key" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --arithmetic-conf -start-point " + Local_start_point + " -monomial-key " + Decoy_monomial_key + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-binomial-key -binomial-key " + Decoy_binomial_key

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( Decoy_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def load_Shared_Decoy_binomial_key_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "load_Shared_Decoy_binomial_key" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_binomial_key = get_from_layout ( slayout_local, "Shared_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Shared_binomial_key, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        keynum = get_from_layout ( slayout_local, "Decoy_binomial_key_selection" )["fields"][2]["selection"]
        Decoy_binomial_key = get_from_layout ( slayout_local, "Decoy_binomial_key_" + keynum )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Decoy_binomial_key, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_binomial_key + " -to-encode " + Decoy_binomial_key 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj,error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( Decoy_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def encrypt_and_sign_message_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "encrypt_and_sign_message" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_binomial_key = get_from_layout ( slayout_local, "Local_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Local_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_monomial_key = get_from_layout ( slayout_local, "Local_monomial_key" )["fields"][2]["display"]
        error, popup_obj = check_monomial_key_wrapper( Local_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        plain_text = get_from_layout ( slayout_local, "Local_plain_text_message" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_readable( plain_text, row_index, popup_obj )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    ring_size = int(get_from_layout ( slayout_local, "ring_signature_size" )["fields"][2]["selection"])
    for i in range (0, ring_size):
        Decoy_binomial_key = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Decoy_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_binomial_key = get_from_layout ( slayout_local, "Shared_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Shared_binomial_key, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        encrypted_text = get_from_layout ( slayout_local, "Shared_encrypted_message" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( encrypted_text, row_index, popup_obj )

    if error == 0 :
        ring_signature = get_from_layout ( slayout_local, "Shared_ring_signature" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( ring_signature, row_index, popup_obj )

    if error == 0 :

        shared_binomial_key_tmp = cache_dir + "/shared_binomial_key_" + str(random.randint(0,10000))
        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_binomial_key + " -to-encode " + shared_binomial_key_tmp

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( shared_binomial_key_tmp, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "encrypt asymmetric" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --arithmetic-conf -binomial-key " + shared_binomial_key_tmp + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --encrypt-asymmetric -plain-text " + plain_text + " -cipher-text " + encrypted_text 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_asy_encryption_wrapper( encrypted_text, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make ring signature" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --arithmetic-conf -binomial-key " + Local_binomial_key + " -monomial-key " + Local_monomial_key + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-ring-signature -plain-text " + encrypted_text + " -verifier-binomial-key " + shared_binomial_key_tmp + " " 
        cmd_str = cmd_str + " -ring-signature " + ring_signature + " "
        for i in range (0, ring_size):
            cmd_str = cmd_str + " -add-decoy-binomial-key " + get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )["fields"][2]["display"] + " "

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_ring_signature_wrapper( ring_signature, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str

def verify_and_decrypt_message_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, logging_info_str, cache_dir, log_file = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "verify_and_decrypt_message" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_ring_signature = get_from_layout ( slayout_local, "Shared_ring_signature" )["fields"][2]["display"]
        error, popup_obj = check_ring_signature_wrapper( Shared_ring_signature, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_monomial_key = get_from_layout ( slayout_local, "Local_monomial_key" )["fields"][2]["display"]
        error, popup_obj = check_monomial_key_wrapper( Local_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        encrypted_text = get_from_layout ( slayout_local, "Shared_encrypted_message" )["fields"][2]["display"]
        error, popup_obj = check_asy_encryption_wrapper( encrypted_text, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_decrypted_message = get_from_layout ( slayout_local, "Local_decrypted_message" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_decrypted_message, row_index, popup_obj )

    if error == 0 :
        Sender_binomial_key = get_from_layout ( slayout_local, "Sender_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Sender_binomial_key, row_index, popup_obj )

    if error == 0 :
        Local_received_ring_signature = get_from_layout ( slayout_local, "Local_received_ring_signature" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( Local_received_ring_signature, row_index, popup_obj )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_ring_signature + " -to-encode " + Local_received_ring_signature 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_ring_signature_wrapper( Local_received_ring_signature, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        lib_info = 1
        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "check ring signature" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password  "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password  " 
        cmd_str = cmd_str + " --arithmetic-conf -monomial-key " + Local_monomial_key + " -ring-signature " + Local_received_ring_signature + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_info_str + " --check-ring-signature -plain-text " + encrypted_text + " -signer-binomial-key " + Sender_binomial_key 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( Sender_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        jresponse_str = os.popen("cat " + log_file).read()
        if jresponse_str == "" :
            error = 1

    if error == 0 :
        jresponse_obj = json.loads( jresponse_str )
        error = 1
        if jresponse_obj["message_type"] == "info" :
            if jresponse_obj["function"] == "xrn_check_ring_signature" :
                if jresponse_obj["result"] == "PASS" :
                    error = 0

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decipher asymmetric" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --arithmetic-conf -monomial-key " + Local_monomial_key + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --decipher-asymmetric -plain-text " + Local_decrypted_message + " -cipher-text " + encrypted_text 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_if_file_is_readable( Local_decrypted_message, row_index, popup_obj  )


    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


def encrypt_sign_and_permute_button () :

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str
    error = 0; lib_info = 0
    logging_str, _, cache_dir, _ = generate_log_string( )
    architecture = get_from_layout( slayout_local, "running_bit_architecture" )["fields"][2]["selection"]

    panel_name = get_from_layout( slayout_local, "encrypt_sign_and_permute" )["fields"][0]["display"]
    popup_obj, row_index = start_xmessage_popup( panel_name , "input checks" )

    if error == 0 :
        Local_dump_encoding_param = get_from_layout ( slayout_local, "Local_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Local_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_binomial_key = get_from_layout ( slayout_local, "Local_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Local_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_monomial_key = get_from_layout ( slayout_local, "Local_monomial_key" )["fields"][2]["display"]
        error, popup_obj = check_monomial_key_wrapper( Local_monomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_xmatrix = get_from_layout ( slayout_local, "Local_xmatrix" )["fields"][2]["display"]
        error, popup_obj = check_matrx_wrapper( Local_xmatrix, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Local_received_ring_signature = get_from_layout ( slayout_local, "Local_received_ring_signature" )["fields"][2]["display"]
        error, popup_obj = check_ring_signature_wrapper( Local_received_ring_signature, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        plain_text = get_from_layout ( slayout_local, "Local_plain_text_message" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_readable( plain_text, row_index, popup_obj )

    if error == 0 :
        Shared_dump_encoding_param = get_from_layout ( slayout_local, "Shared_encoding_parameters" )["fields"][2]["display"]
        error, popup_obj = check_encoding_param_wrapper( Shared_dump_encoding_param, cache_dir, "", architecture, popup_obj, row_index )

    ring_size = int(get_from_layout ( slayout_local, "ring_signature_size" )["fields"][2]["selection"])
    for i in range (0, ring_size):
        Decoy_binomial_key = get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Decoy_binomial_key, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        Shared_binomial_key = get_from_layout ( slayout_local, "Shared_binomial_key" )["fields"][2]["display"]
        error, popup_obj = check_binomial_key_wrapper( Shared_binomial_key, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        encrypted_text = get_from_layout ( slayout_local, "Shared_encrypted_message" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( encrypted_text, row_index, popup_obj )

    if error == 0 :
        ring_signature = get_from_layout ( slayout_local, "Shared_ring_signature" )["fields"][2]["display"]
        error, popup_obj = check_if_file_is_writable( ring_signature, row_index, popup_obj )

    if error == 0 :

        shared_binomial_key_tmp = cache_dir + "/shared_binomial_key_" + str(random.randint(0,10000))
        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "decode encode" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        Shared_ring_signature_tmp = cache_dir + "/Shared_ring_signature_tmp_" + str(random.randint(0,10000))

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + logging_str + " --decode-encode -to-decode " + Shared_binomial_key + " -to-encode " + shared_binomial_key_tmp

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_binomial_key_wrapper( shared_binomial_key_tmp, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "encrypt asymmetric" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --arithmetic-conf -binomial-key " + shared_binomial_key_tmp + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --encrypt-asymmetric -plain-text " + plain_text + " -cipher-text " + encrypted_text 

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_asy_encryption_wrapper( encrypted_text, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :

        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "make ring signature" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})
        shared_ring_signature_tmp = cache_dir + "/shared_ring_signature_" + str(random.randint(0,10000))

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --arithmetic-conf -binomial-key " + Local_binomial_key + " -monomial-key " + Local_monomial_key + " "
        cmd_str = cmd_str + " --sequence-conf -xmatrix " + Local_xmatrix + " "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --make-ring-signature -plain-text " + encrypted_text + " -verifier-binomial-key " + shared_binomial_key_tmp + " " 
        cmd_str = cmd_str + " -ring-signature " + shared_ring_signature_tmp + " "
        for i in range (0, ring_size):
            cmd_str = cmd_str + " -add-decoy-binomial-key " + get_from_layout ( slayout_local, "Decoy_binomial_key_" + str(i) )["fields"][2]["display"] + " "

        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_ring_signature_wrapper( shared_ring_signature_tmp, cache_dir, Local_dump_encoding_param, "", architecture, popup_obj, row_index )

    if error == 0 :
        popup_obj, row_index = add_row_xmessage_popup( popup_obj, "permute ring signature" )
        popup_obj[0]["rows"][row_index]["fields"].append({"type": "archive", "selection": "command", "items":[]})

        cmd_str = "xrnlib-cli --decoding-conf -encoding-param " + Local_dump_encoding_param + " -no-password " 
        cmd_str = cmd_str + " --encoding-conf -encoding-param " + Shared_dump_encoding_param + " -no-password "
        cmd_str = cmd_str + " --permutation-conf -arch " + architecture + " "
        cmd_str = cmd_str + logging_str + " --permute-ring-signature -signer-binomial-key " + Local_binomial_key + " "
        cmd_str = cmd_str + " -verifier-binomial-key " + shared_binomial_key_tmp + " "
        cmd_str = cmd_str + " -signer-ring-signature " + shared_ring_signature_tmp + " "
        cmd_str = cmd_str + " -verifier-ring-signature " + Local_received_ring_signature + " "
        cmd_str = cmd_str + " -permuted-ring-signature " + ring_signature + " "
 
        input_local_check, output_local_check, input_remote_check, output_remote_check, cmd_output = xrncmd_run ( cmd_str )

        popup_obj[0]["rows"][row_index]["fields"][2]["items"].append({"display": "command", "data": cmd_str })
        popup_obj, error = append_logs( popup_obj, cmd_str )

    if error == 0 :
        popup_obj = append_execution_logs( popup_obj, input_local_check, output_local_check, input_remote_check, output_remote_check )
        error, popup_obj = check_ring_signature_wrapper( ring_signature, cache_dir, Shared_dump_encoding_param, "", architecture, popup_obj, row_index )

    popup_obj = rename_final_popup_panel_name(panel_name, popup_obj, error)
    popup_str = json.dumps(popup_obj)

    os.system("rm -rf " + cache_dir)
    return popup_str


